#pragma once
#include <QDebug>
#include <QFile>
#include <QFileSystemWatcher>
#include <QApplication>
#include <QDesktopServices>
#include <QUrl>
#include <QFileInfo>
#include <QProcess>

#define cout qDebug() << __FILE__ << __LINE__ << ":"
#define toHex( X ) QString::number( X, 16 )


inline void loadQssFile(QString fileName) {
  QFile file(fileName);
  file.open(QFile::ReadWrite |
            QIODevice::Text);  // 如果文件不存在，会创建该文件
  qApp->setStyleSheet(file.readAll());
  file.close();
}

inline void watchQssFile(QString fileName) {
  QFileSystemWatcher* watch = new QFileSystemWatcher(qApp);
  watch->addPath(fileName);
  QObject::connect(watch, &QFileSystemWatcher::fileChanged, [fileName] {
//    cout << "watchQssFile";
    loadQssFile(fileName);
  });
}
